{extend name="base" /}
{block name="main"}
	<div >
	<form action="{:url('saveConfig')}" method="post" style="line-height: 30px;margin:10px;" autocomplete="off">
			<div class="main-title cf">
				<div class="addoncfg-title">插件配置 [ {$data.title} ]</div>
			</div>
			{foreach name="data['config']" item="form" key="o_key"}
				<div class="form-item cf">
				{present name="form.title"}
					<label class="item-label">
						<span style="font-weight: bold;">{$form.title|default=''}</span>
						
					</label>
					{/present}
						{switch name="form.type"}
							{case value="tips"}
							<div>
								{$form.value}
							</div>
							{/case}
							{case value="text"}
							<div>
								<input type="text" name="config[{$o_key}]" class="text input-large" value="{$form.value}"  style="width:400px;"><?php if(isset($form['tips'])){ ?><span>{$form.tips}</span><?php } ?>
							</div>
							{/case}
							{case value="password"}
							<div>
								<input type="password" name="config[{$o_key}]" class="text input-large" value="{$form.value}">
							</div>
							{/case}
							{case value="hidden"}
								<input type="hidden" name="config[{$o_key}]" value="{$form.value}">
							{/case}
							{case value="radio"}
							<div class="layui-form">
								{foreach name="form.options" item="opt" key="opt_k"}
									<label class="radio">
										<input type="radio" name="config[{$o_key}]" value="{$opt_k}" {eq name="form.value" value="$opt_k"} checked{/eq} title="{$opt}">
									</label>
								{/foreach}
							</div>
							{/case}
							{case value="checkbox"}
							<div>
								{foreach name="form.options" item="opt" key="opt_k"}
									<label class="checkbox">
										{php}
											is_null($form["value"]) && $form["value"] = array();
										{/php}
										<input type="checkbox" name="config[{$o_key}][]" value="{$opt_k}" {in name="opt_k" value="$form.value"}checked{/in}>{$opt}
									</label>
								{/foreach}
							</div>
							{/case}
							{case value="select"}
							<div>
								<select name="config[{$o_key}]">
									{foreach name="form.options" item="opt" key="opt_k"}
										<option value="{$opt_k}" {eq name="form.value" value="$opt_k"} selected{/eq}>{$opt}</option>
									{/foreach}
								</select>
							</div>
							{/case}
							{case value="textarea"}
							<div>
								<label class="textarea input-large">
									<textarea name="config[{$o_key}]" style="width:500px;height:200px;">{$form.value}</textarea>
								</label>
							</div>
							{/case}
							
							{case value="group"}
								<ul class="tab-nav nav">
									{volist name="form.options" id="li"}
										<li data-tab="tab{$i}" {eq name="i" value="1"}class="current" {/eq} ><a href="javascript:void(0);">{$li.title}</a></li>
									{/volist}
									<div style="clear: both;"></div>
								</ul>
								<div class="tab-content">
								{volist name="form.options" id="tab"}
									<div id="tab{$i}" class="tab-pane {eq name="i" value="1"}in{/eq} tab{$i}">
										{foreach name="tab['options']" item="tab_form" key="o_tab_key"}
										<label class="item-label">
											<span style="font-weight: bold;">{$tab_form.title|default=''}</span>
											{present name="tab_form.tip"}
												<span class="check-tips">{$tab_form.tip}</span>
											{/present}
										</label>
										<div>
											{switch name="tab_form.type"}
												{case value="tips"}
												<div>
													{$form.value}
												</div>
												{/case}
												{case value="text"}
													<input type="text" name="config[{$o_tab_key}]" class="text input-large" value="{$tab_form.value}" style="width:400px;">
												{/case}
												{case value="password"}
													<input type="password" name="config[{$o_tab_key}]" class="text input-large" value="{$tab_form.value}">
												{/case}
												{case value="hidden"}
													<input type="hidden" name="config[{$o_tab_key}]" value="{$tab_form.value}">
												{/case}
												{case value="radio"}
													{foreach name="tab_form.options" item="opt" key="opt_k"}
														<label class="layui-form radio">
															<input type="radio" name="config[{$o_tab_key}]" value="{$opt_k}" {eq name="tab_form.value" value="$opt_k"} checked{/eq} title="{$opt}">
														</label>
													{/foreach}
												{/case}
												{case value="checkbox"}
													{foreach name="tab_form.options" item="opt" key="opt_k"}
														<label class="checkbox">
															{php} 
															is_null($tab_form["value"]) && $tab_form["value"] = array();
															{/php}
															<input type="checkbox" name="config[{$o_tab_key}][]" value="{$opt_k}" {in name="opt_k" value="$tab_form.value"} checked{/in}>{$opt}
														</label>
													{/foreach}
												{/case}
												{case value="select"}
													<select name="config[{$o_tab_key}]">
														{foreach name="tab_form.options" item="opt" key="opt_k"}
															<option value="{$opt_k}" {eq name="tab_form.value" value="$opt_k"} selected{/eq}>{$opt}</option>
														{/foreach}
													</select>
												{/case}
												{case value="textarea"}
													<label>
														<textarea name="config[{$o_tab_key}]">{$tab_form.value}</textarea>
													</label>
												{/case}
												
												{/switch}
											</div>
										{/foreach}
									</div>
								{/volist}
								</div>
							{/case}
						{/switch}
					</div>
			{/foreach}
		<div class="form-item cf wst-bottombar" style='padding-left:130px;padding-top:10px'>
		<input type="hidden" name="id" value="{$addonId}" readonly/>
		<button type="submit" class="btn submit-btn ajax-post btn-primary btn-mright" ><i class="fa fa-check"></i>确 定</button>&nbsp;&nbsp;&nbsp;&nbsp;
		<button type="button"  class='btn' onclick="location.href='{:url("admin/addons/index")}'"><i class="fa fa-angle-double-left"></i>返回</button>
		</div>
	</form>
	</div>
{/block}

{block name="js"}
<script type="text/javascript" charset="utf-8">

$(function(){
	 $(".tab-nav li").click(function(){
	        var self = $(this), target = self.data("tab");
	        self.addClass("current").siblings(".current").removeClass("current");
	        //window.location.hash = "#" + target.substr(3);
	        $(".tab-pane.in").removeClass("in");
	        $("." + target).addClass("in");
	}).filter("[data-tab=tab" + window.location.hash.substr(1) + "]").click();
})
</script>
{/block}
